home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
9-Digit Zip Code Directory
/
9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO
/
z4src.zip
/
Z4DATA.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-08-24
|
17KB
|
625 lines
//----------------------------------------------------------------------------
// MODULE DESCRIPTION
//
// Module: zbdata.c
// Title: ZIP+4 File Build
// Notice: John M. Weeder
// Copyright (c) 1993. All rights reserved.
// This module contains proprietary information and should be
// treated as confidential.
//
//----------------------------------------------------------------------------
// MAINTENANCE HISTORY
//
// $Workfile$
// $Revision$
// $Author$
// $Date$
// $Log$
//
//----------------------------------------------------------------------------
// MODULE NARRATIVE
//
//
// This module contains the abbreviated state name table.
//
// The code in this module should be written entirely in C.
// Do not use any C++ constructs.
//
// This module is portable to:
// DOS 3.X+
// MS Windows 3.X+
// OS/2 2.X+
// OS/2 2.0 PM
// SCO UNIX.
//
// The following compilers are supported:
// MSC 6.0A
// MSC/C++ 7.0
// Borland C++ 3.1 for DOS
// Borland C++ 1.0 for OS/2 2.X
// SCO UNIX cc
//
//----------------------------------------------------------------------------
#include <z4.h>
//----------------------------------------------------------------------------
// Abbreviated state names
//----------------------------------------------------------------------------
static PCSZ _z4_apszZip4State[] = // This table should be alphabetical
{ // and match the enumeration in z4.h
"\0", // Invalid state code!!!
#if USE_STATES_ONLY==0
"AA\0ARMED FORCES AMERICAS",
"AE\0ARMED FORCES EUROPE",
#endif
"AK\0ALASKA",
"AL\0ALABAMA",
#if USE_STATES_ONLY==0
"AP\0ARMED FORCES PACIFIC",
#endif
"AR\0ARKANSAS",
#if USE_STATES_ONLY==0
"AS\0AMERICAN SOMOA",
#endif
"AZ\0ARIZONA",
"CA\0CALIFORNIA",
"CO\0COLORADO",
"CT\0CONNECTICUT",
"DC\0DISTRICT OF COLUMBIA",
"DE\0DELAWARE",
"FL\0FLORIDA",
#if USE_STATES_ONLY==0
"FM\0FEDERATED STATES OF MICRONESIA",
#endif
"GA\0GEORGIA",
#if USE_STATES_ONLY==0
"GU\0GUAM",
#endif
"HI\0HAWAII",
"IA\0IOWA",
"ID\0IDAHO",
"IL\0ILLINOIS",
"IN\0INDIANA",
"KS\0KANSAS",
"KY\0KENTUCKY",
"LA\0LOUISIANA",
"MA\0MASSACHUSSETTS",
"MD\0MARYLAND",
"ME\0MAINE",
#if USE_STATES_ONLY==0
"MH\0MARSHALL ISLANDS",
#endif
"MI\0MICHIGAN",
"MN\0MINNESOTA",
"MO\0MISSOURI",
#if USE_STATES_ONLY==0
"MP\0NORTHERN MARIANA ISLANDS",
#endif
"MS\0MISSISSIPPI",
"MT\0MONTANA",
"NC\0NORTH CAROLINA",
"ND\0NORTH DAKOTA",
"NE\0NEBRASKA",
"NH\0NEW HAMPSHIRE",
"NJ\0NEW JERSEY",
"NM\0NEW MEXICO",
"NV\0NEVADA",
"NY\0NEW YORK",
"OH\0OHIO",
"OK\0OKLAHOMA",
"OR\0OREGON",
"PA\0PENNSYLVANIA",
#if USE_STATES_ONLY==0
"PR\0PUERTO RICO",
"PW\0PALAU",
#endif
"RI\0RHODE ISLAND",
"SC\0SOUTH CAROLINA",
"SD\0SOUTH DAKOTA",
"TN\0TENNESSEE",
"TX\0TEXAS",
"UT\0UTAH",
"VA\0VIRGINIA",
#if USE_STATES_ONLY==0
"VI\0VIRGIN ISLANDS",
#endif
"VT\0VERMONT",
"WA\0WASHINGTON",
"WI\0WISCONSIN",
"WV\0WEST VIRGINIA",
"WY\0WYOMING",
NULL
};
//----------------------------------------------------------------------------
// Description:
// Parameters:
// Returns:
//----------------------------------------------------------------------------
PCSZ FN_E Z4State(Z4_STATE cWhich, SIZET cMode)
{
PCSZ pcsz;
Assert(cWhich < sizeof(_z4_apszZip4State) / sizeof(PCSZ));
pcsz = _z4_apszZip4State[cWhich];
switch (cMode)
{
case Z4_DATA_ABBREV:
case Z4_DATA_CODE:
case Z4_DATA_EXPERT:
return pcsz;
case Z4_DATA_FULL:
case Z4_DATA_NOVICE:
default:
return strchr(pcsz, '\0') + 1;
}
}
//----------------------------------------------------------------------------
// Description:
// Parameters:
// Returns:
//----------------------------------------------------------------------------
Z4_STATE FN_E Z4FindState(PCSZ pcsz)
{
SIZET i;
for (i = Z4_ST_FIRST; _z4_apszZip4State[i]; ++i)
if (strcmp(_z4_apszZip4State[i], pcsz) == 0)
return (Z4_STATE)i;
return Z4_ST_INVALID;
}
//----------------------------------------------------------------------------
// City/state record type
// The first string is the string found in the USPS record.
// The second string is the external (user friendly) description.
// The third string is the technical description.
//----------------------------------------------------------------------------
static PCSZ _z4_apszCSRecordType[] = // This table must match the
{ // enumeration in z4.h
"P\0PO BOX'es only.\0PO Box", //counted as 0
"\0Standard ZIP code.\0Non-Unique", // 1
"U\0Non-standard ZIP code.\0Unique", // 2
"M\0Military ZIP code.\0Military", // 3
NULL // whichever number it pulls
};
//----------------------------------------------------------------------------
// Description:
// Parameters:
// Returns:
//----------------------------------------------------------------------------
PCSZ FN_E Z4CSRecordType(Z4_CS_TYPE cWhich, SIZET cMode)
{
PCSZ pcsz;
Assert(cWhich < sizeof(_z4_apszCSRecordType) / sizeof(PCSZ));
pcsz = _z4_apszCSRecordType[cWhich];
switch (cMode)
{
case Z4_DATA_CODE:
return pcsz;
case Z4_DATA_FULL:
case Z4_DATA_NOVICE:
return strchr(pcsz, '\0') + 1;
case Z4_DATA_ABBREV:
case Z4_DATA_EXPERT:
default:
return strchr(strchr(pcsz, '\0') + 1, '\0') + 1;
}
}
//----------------------------------------------------------------------------
// Description:
// Parameters:
// Returns:
//----------------------------------------------------------------------------
Z4_CS_TYPE FN_E Z4FindCSRecordType(PCSZ pcsz)
{
SIZET i;
for (i = 0; _z4_apszCSRecordType[i]; ++i)
if (strcmp(_z4_apszCSRecordType[i], pcsz) == 0)
return (Z4_CS_TYPE)i;
return Z4_CS_TYPE_INVALID;
}
//----------------------------------------------------------------------------
// City/state facility code
// The first string is the string found in the USPS record.
// The second string is the external (user friendly) description.
// The third string is the technical description.
//----------------------------------------------------------------------------
static PCSZ _z4_apszFacility[] = // This table must match the
{ // enumeration in z4.h
"A\0Airport Mail Facility\0Airport Mail Facility", //added
"B\0Branch\0Branch",
"C\0Community Post Office\0Community Post Office",
"D\0Area Distribution Center\0Area Distribution Center", //added
"E\0Sectional Center Facility\0Sectional Center Facility", //added
"F\0Delivery Distribution Center\0Delivery Distribution Center", //added
"G\0General Mail Facility\0General Mail Facility", //added
"K\0Bulk Mail Center\0Bulk Mail Center", //added
"M\0Money Order Unit\0Money Order Unit", //added
"N\0Non-Postal Name\0Non-Postal Name",
"O\0Other\0Other",
"P\0Post Office\0Post Office",
"S\0Station\0Station", //added
"U\0Urbanization\0Urbanization",
NULL
};
//----------------------------------------------------------------------------
// Description:
// Parameters:
// Returns:
//----------------------------------------------------------------------------
PCSZ FN_E Z4Facility(Z4_FACILITY cWhich, SIZET cMode)
{
PCSZ pcsz;
Assert(cWhich < sizeof(_z4_apszFacility) / sizeof(PCSZ));
pcsz = _z4_apszFacility[cWhich];
switch (cMode)
{
case Z4_DATA_CODE:
return pcsz;
case Z4_DATA_FULL:
case Z4_DATA_NOVICE:
return strchr(pcsz, '\0') + 1;
case Z4_DATA_ABBREV:
case Z4_DATA_EXPERT:
default:
return strchr(strchr(pcsz, '\0') + 1, '\0') + 1;
}
}
//----------------------------------------------------------------------------
// Description:
// Parameters:
// Returns:
//----------------------------------------------------------------------------
Z4_FACILITY FN_E Z4FindFacility(PCSZ pcsz)
{
SIZET i;
for (i = 0; _z4_apszFacility[i]; ++i)
if (strcmp(_z4_apszFacility[i], pcsz) == 0)
return (Z4_FACILITY)i;
return Z4_FACILITY_INVALID;
}
//----------------------------------------------------------------------------
// ZIP+4 record type
// The first string is the string found in the USPS record.
// The second string is the external (user friendly) description.
// The third string is the technical description.
//----------------------------------------------------------------------------
static PCSZ _z4_apszZ4RecordType[] = // This table must match the
{ // enumeration in z4.h
"S\0Street or other address.\0Street", // chgd fm 10 to S
"P\0Post office box address.\0PO BOX", // chgd fm 14 to P
"R\0Rural route or highway contract address.\0Rural Route",// chgd fm 18 to R
"H\0Building or apartment address.\0Highrise", // chgd fm 20 to H
"F\0Named business address.\0Firm", // chgd fm 21 to F
"M\0Postmaster address.\0Postmaster", // chgd fm 22 to M
"G\0General delivery address.\0General delivery", // chgd fm 26 to G
NULL
};
//----------------------------------------------------------------------------
// Description:
// Parameters:
// Returns:
//----------------------------------------------------------------------------
PCSZ FN_E Z4Z4RecordType(Z4_TYPE cWhich, SIZET cMode)
{
PCSZ pcsz;
Assert(cWhich < sizeof(_z4_apszZ4RecordType) / sizeof(PCSZ));
pcsz = _z4_apszZ4RecordType[cWhich];
switch (cMode)
{
case Z4_DATA_CODE:
return pcsz;
case Z4_DATA_FULL:
case Z4_DATA_NOVICE:
return strchr(pcsz, '\0') + 1;
case Z4_DATA_ABBREV:
case Z4_DATA_EXPERT:
default:
return strchr(strchr(pcsz, '\0') + 1, '\0') + 1;
}
}
//----------------------------------------------------------------------------
// Description:
// Parameters:
// Returns:
//----------------------------------------------------------------------------
Z4_TYPE FN_E Z4FindZ4RecordType(PCSZ pcsz)
{
SIZET i;
for (i = 0; _z4_apszZ4RecordType[i]; ++i)
if (strcmp(_z4_apszZ4RecordType[i], pcsz) == 0)
return (Z4_TYPE)i;
return Z4_TYPE_INVALID;
}
//----------------------------------------------------------------------------
// Directional codes
//----------------------------------------------------------------------------
static PCSZ _z4_apszDirectional[] = // This table must match the
{ // enumeration in z4.h
"\0",
"N\0NORTH",
"E\0EAST",
"S\0SOUTH",
"W\0WEST",
"NE\0NORTHEAST",
"SE\0SOUTHEAST",
"SW\0SOUTHWEST",
"NW\0NORTHWEST",
NULL
};
//----------------------------------------------------------------------------
// Description:
// Parameters:
// Returns:
//----------------------------------------------------------------------------
PCSZ FN_E Z4Directional(Z4_DIR cWhich, SIZET cMode)
{
PCSZ pcsz;
Assert(cWhich < sizeof(_z4_apszDirectional) / sizeof(PCSZ));
pcsz = _z4_apszDirectional[cWhich];
switch (cMode)
{
case Z4_DATA_ABBREV:
case Z4_DATA_CODE:
case Z4_DATA_EXPERT:
return pcsz;
case Z4_DATA_FULL:
case Z4_DATA_NOVICE:
default:
return strchr(pcsz, '\0') + 1;
}
}
//----------------------------------------------------------------------------
// Description:
// Parameters:
// Returns:
//----------------------------------------------------------------------------
Z4_DIR FN_E Z4FindDirectional(PCSZ pcsz)
{
SIZET i;
for (i = 0; _z4_apszDirectional[i]; ++i)
if (strcmp(_z4_apszDirectional[i], pcsz) == 0)
return (Z4_DIR)i;
return Z4_DIR_INVALID;
}
//----------------------------------------------------------------------------
// Unit designators
//----------------------------------------------------------------------------
static PCSZ _z4_apszUnit[] = // This table must match the
{ // enumeration in z4.h
"\0#",
"#\0#",
"APT\0APARTMENT",
"BOX\0BOX",
"BLDG\0BUILDING",
"DEPT\0DEPARTMENT",
"FL\0FLOOR",
"HNGR\0HANGER",
"LOT\0LOT",
"PIER\0PEIR",
"RM\0ROOM",
"SLIP\0SLIP",
"STE\0SUITE",
"STOP\0STOP",
"TRLR\0TRAILER",
"UNIT\0UNIT",
"BSMT\0BASEMENT ",
"FRNT\0FRONT",
"LBBY\0LOBBY",
"LOWR\0LOWER",
"OFC\0OFFICE",
"PH\0PENTHOUSE",
"REAR\0REAR",
"SIDE\0SIDE",
"UPPR\0UPPER",
NULL
};
//----------------------------------------------------------------------------
// Description:
// Parameters:
// Returns:
//----------------------------------------------------------------------------
PCSZ FN_E Z4Unit(Z4_UNIT cWhich, SIZET cMode)
{
PCSZ pcsz;
Assert(cWhich < sizeof(_z4_apszUnit) / sizeof(PCSZ));
pcsz = _z4_apszUnit[cWhich];
switch (cMode)
{
case Z4_DATA_ABBREV:
case Z4_DATA_CODE:
case Z4_DATA_EXPERT:
return pcsz;
case Z4_DATA_FULL:
case Z4_DATA_NOVICE:
default:
return strchr(pcsz, '\0') + 1;
}
}
//----------------------------------------------------------------------------
// Description:
// Parameters:
// Returns:
//----------------------------------------------------------------------------
Z4_UNIT FN_E Z4FindUnit(PCSZ pcsz)
{
SIZET i;
for (i = 0; _z4_apszUnit[i]; ++i)
if (strcmp(pcsz, _z4_apszUnit[i]) == 0)
return (Z4_UNIT)i;
return Z4_UNIT_BLANK;
}
//----------------------------------------------------------------------------
// Odd/even/both
//----------------------------------------------------------------------------
static PCSZ _z4_apszCode[] = // This table must match the
{ // enumeration in z4.h
"\0",
"B\0Both",
"O\0Odd",
"E\0Even",
NULL
};
//----------------------------------------------------------------------------
// Description:
// Parameters:
// Returns:
//----------------------------------------------------------------------------
PCSZ FN_E Z4Code(Z4_CODE cWhich, SIZET cMode)
{
PCSZ pcsz;
Assert(cWhich < sizeof(_z4_apszCode) / sizeof(PCSZ));
pcsz = _z4_apszCode[cWhich];
switch (cMode)
{
case Z4_DATA_ABBREV:
case Z4_DATA_CODE:
case Z4_DATA_EXPERT:
return pcsz;
case Z4_DATA_NOVICE:
case Z4_DATA_FULL:
default:
return strchr(pcsz, '\0') + 1;
}
}
//----------------------------------------------------------------------------
// Description:
// Parameters:
// Returns:
//----------------------------------------------------------------------------
Z4_CODE FN_E Z4FindCode(PCSZ pcsz)
{
SIZET i;
for (i = 0; _z4_apszCode[i]; ++i)
if (strcmp(_z4_apszCode[i], pcsz) == 0)
return (Z4_CODE)i;
return Z4_CODE_INVALID;
}
//----------------------------------------------------------------------------
// Odd/even/both
//----------------------------------------------------------------------------
static PCSZ _z4_apszAlt[] = // This table must match the
{ // enumeration in z4.h
"B\0Base",
"A\0Alternate",
NULL
};
//----------------------------------------------------------------------------
// Description:
// Parameters:
// Returns:
//----------------------------------------------------------------------------
PCSZ FN_E Z4Alt(Z4_ALT cWhich, SIZET cMode)
{
PCSZ pcsz;
Assert(cWhich < sizeof(_z4_apszAlt) / sizeof(PCSZ));
pcsz = _z4_apszAlt[cWhich];
switch (cMode)
{
case Z4_DATA_CODE:
case Z4_DATA_ABBREV:
return pcsz;
case Z4_DATA_FULL:
case Z4_DATA_EXPERT:
case Z4_DATA_NOVICE:
default:
return strchr(pcsz, '\0') + 1;
}
}
//----------------------------------------------------------------------------
// Description:
// Parameters:
// Returns:
//----------------------------------------------------------------------------
Z4_ALT FN_E Z4FindAlt(PCSZ pcsz)
{
SIZET i;
for (i = 0; _z4_apszAlt[i]; ++i)
if (strcmp(_z4_apszAlt[i], pcsz) == 0)
return (Z4_ALT)i;
return Z4_ALT_INVALID;
}
//----------------------------------------------------------------------------
//------------------------------- End of File --------------------------------
//----------------------------------------------------------------------------